/***********************************************************
 *
 * Gaoth
 * Copyright (c) 2011- Marcus Lundgren
 *
 * This software is provided 'as-is', without any express or implied warranty.
 * In no event will the authors be held liable for any damages arising from
 * the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it freely,
 * subject to the following restrictions:
 *
 *  1. The origin of this software must not be misrepresented; you must not
 *     claim that you wrote the original software. If you use this software
 *     in a product, an acknowledgment in the product documentation would be
 *     appreciated but is not required.
 *
 *  2. Altered source versions must be plainly marked as such,
 *     and must not be misrepresented as being the original software.
 *
 *  3. This notice may not be removed or altered from any source distribution.
 *
 ***********************************************************/

#pragma once

#include <irrlicht/irrlicht.h>

#include "states/i_state.h"
#include "states/about_state.h"
#include "states/game_state.h"
#include "states/menu_state.h"

#include "../model/model.h"
#include "../network/network_manager.h"

class GameWindow
{
public:
    /**
     * Constructor.
     *
     * @param model a pointer to the model
     */
    GameWindow( Model *model, NetworkManager *net_man );
    /**
     * Destructor.
     */
    ~GameWindow();
    /**
     * Updates the current state in the window. It will also switch the state
     * if needed.
     *
     * @param time in seconds since last frame update.
     * @return false if the program should terminate, true otherwise.
     */
    bool update( const float time );
    /**
     * Draws the current state.
     */
    void draw() const;
private:
    irr::IrrlichtDevice *_device;
    irr::video::IVideoDriver *_driver;
    irr::scene::ISceneManager *_scene_mgr;
    irr::gui::IGUIEnvironment *_gui_env;

    Model *_model;

    IState *_current_state;

    AboutState *_about_state;
    GameState *_game_state;
    MenuState *_menu_state;

    /**
     * Switches to the given state.
     *
     * @param state the state to switch to
     */
    void switch_state( States state );

    // Illegal
    GameWindow( const GameWindow& );
    GameWindow& operator=( const GameWindow& );
};
